package com.ruoyi.accounting.enums;

import lombok.Data;

import java.util.Objects;

/**
 * 分类种类枚举
 */
public enum ClassificationTypeEnum {

    INCOME(1, "收入"),
    EXPENDITURE(2, "支出");
    private final Integer code;
    private final String name;

    ClassificationTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static boolean isValidCode(Integer code) {
        for (ClassificationTypeEnum classificationType : ClassificationTypeEnum.values()) {
            if (Objects.equals(classificationType.getCode(), code)) {
                return true;
            }
        }

        return false;
    }

    public Integer getCode() {
        return code;
    }
}
